#include <tut.h>
#include "Pennyworth.h"

namespace tut
{
	struct basic_daylight
	{
	};
	typedef test_group<basic_daylight> daylight;
	typedef daylight::object daylight_object;
}

namespace
{	
	tut::daylight tf("Pennyworth::Sensors::Daylight Sensor Tests");
}

namespace tut
{
	template<>
	template<>
	void daylight_object::test<1>()
	{
		Pennyworth::Sensors::DaylightSensor * sensor_plain = new Pennyworth::Sensors::DaylightSensor();
		std::wstring * plain_name = new std::wstring(L"GMT Daylight Sensor");
		ensure_equals("sensor_plain.name = 'GMT Daylight Sensor'", true, (*(sensor_plain->name()) == *plain_name));
		ensure_equals("sensor_plain.latitude = '0'", 0, sensor_plain->latitude());
		delete plain_name;
	}

	template<>
	template<>
	void daylight_object::test<2>()
	{
		std::wstring * detailed_name = new std::wstring(L"Test Sensor");
		std::wstring * detailed_description = new std::wstring(L"This is a test sensor");
		Pennyworth::Sensors::DaylightSensor * sensor_detailed = new Pennyworth::Sensors::DaylightSensor(detailed_name, detailed_description, 43, NULL);

		ensure_equals("sensor_detailed.name = 'Test Sensor'", true, (*(sensor_detailed->name()) == *detailed_name));
		ensure_equals("sensor_detailed.description = 'This is a test sensor'", true, (*(sensor_detailed->description()) == *detailed_description));
		ensure_equals("sensor_detailed.identifier = 43", 43, sensor_detailed->identifier());
		ensure_equals("sensor_detailed.latitude = '0'", 0, sensor_detailed->latitude());
		ensure_equals("sensor_detailed.longitude = '0'", 0, sensor_detailed->longitude());
		
		sensor_detailed->setLatitude(41.90);
		ensure_equals("sensor_detailed.latitude = '41.90'", 41.90, sensor_detailed->latitude());

		sensor_detailed->setLongitude(87.65);
		ensure_equals("sensor_detailed.latitude = '87.65'", 87.65, sensor_detailed->longitude());
		
		delete detailed_name;
		delete detailed_description;
		
		// std::wcout << "Sunrise: " << sensor_detailed->sunrise() << std::endl;
		// std::wcout << "Sunset: " << sensor_detailed->sunset() << std::endl;
	}
}